#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char inputbuf[64] = {0};
char inputbuf2[7] = {0};
char outputbuf[6] = {0};
char outputbuf2[2] = {0x0a, 0x00};
time_t t;
void getUserInput(char* input, int size){
for (int i = 0; i < size; i++){
char x;
read(0, &x, 1);
if (x == 0xa){
break;
}
input[i] = x;
}
}
void rework(){
}
int main(){
getUserInput(inputbuf, 64);
memcpy(inputbuf2, inputbuf, 7);
t = time(NULL);
rework();
write(1, outputbuf, 6);
write(1, outputbuf2, 2);
}printed) is set to either 0x7060 or 0x7066 depending on a local variable. If that local variable is set to 0x2c0, it will be one (probably the "right" one), otherwise it'll be set to Wrong!. So I'm dubbing 0x7060 as right and 0x7066 as wrongcheck value is 0x2c0, then the array right is selected. Each of the 6 elements in this array contains indexes to specific letters that spell out "Wrong!" or "Right!" (my guess)check value is 0x2c0, then the array right is selected. Each of the 6 elements in this array contains indexes to specific letters that spell out "Wrong!" or "Right!" (my guess) Right! if it's rightRight! if it's right check_valuecheck_value is all based on the values stored at global 0x7374, but may have a non-0 starting value[0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0][0x2, 0x3, 0x2, 0x4, 0x1, 0x1, 0x5, 0x1, 0x4, 0x4, 0x2, 0x2, 0x3, 0x2, 0x5, 0x4, 0x2, 0x1, 0x1, 0x3, 0x3, 0x1, 0x1, 0x4, 0x3, 0x1, 0x3, 0x4] (edited)check_itr <= 112check_itr == 113, it hits the default statement in the case switch, initializes check, and exitscheck_value = check_value + (&DAT_00107374)[(ulong)check_itr * 7]; (where we want check_value == 0x2c0) should only be called twice, since there are 2x 0x5 instructionscheck_itr should have values of 3 and 7. Assuming the constants at 0x7374 (which overlaps with 0x7360) also don't change, that means it'll add static value of 0 and 0 ulong, or 8 bytes). Since only every 7th instruction is used, I've marked each valid instruction with the #. It's in the format # index --> value, so # 1 --> 2 means instructions[1] == 0x2value_list now) are added to check_valueulong, or 8 bytes). Since only every 7th instruction is used, I've marked each valid instruction with the #. It's in the format # index --> value, so # 1 --> 2 means instructions[1] == 0x2 instructions) (edited)value_list that are larger, but they're MUCH largerinstructions and value_list will change as time goes oncheck_itr is the instruction pointer lolcheck_itr is the instruction pointer lol value_list and instructions through gdb rn[0x2, 0x2, 0x1, 0x5, 0x4, 0x2, 0x3, 0x5, 0x2, 0x1, 0x3, 0x1, 0x3, 0x3, 0x100000040, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] is 29 long[0x2, 0x2, 0x1, 0x5, 0x4, 0x2, 0x3, 0x5, 0x2, 0x1, 0x3, 0x1, 0x3, 0x3, 0x100000040, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0] is 29 long check_itr is casted to ulong, then every 7th, from 0 to 0x1c in increments of 1check_itr is casted to ulong before * 7, but I might be wrong[0x2, 0x3, 0x2, 0x4, 0x1, 0x1, 0x5, 0x1, 0x4, 0x4, 0x2, 0x2, 0x3, 0x2, 0x5, 0x4, 0x2, 0x1, 0x1, 0x3, 0x3, 0x1, 0x1, 0x4, 0x3, 0x1, 0x3, 0x4, 0x40]0x5 instructions are offset 0x7408 and 0x74e8. So assuming no instructions are changed, then whatever values end up at those 2 offsets will be added to an undetermined starting number for check_value that we need to equal 0x2c01 and the sub_opcode is 2. From what I'm seeing, it'll run like 3 lines, then skip to the bottom of the entire instruction loop and start over again? I haven't quite figured out what code at the top of the loop does, and what the code at the bottom of the loop does, but how does check_itr increase in that case??do {
// block of code where globals are initialized/changed
switch(instructions) {
default:
// do final check and exit
case 1:
switch(sub_opcode) {
// ...
}
case 2:
case 3:
case 4:
case 5:
}
// end block of code where globals are changed
} while (true); (edited) // do final check and exit line1 and the sub_opcode is 2. From what I'm seeing, it'll run like 3 lines, then skip to the bottom of the entire instruction loop and start over again? I haven't quite figured out what code at the top of the loop does, and what the code at the bottom of the loop does, but how does check_itr increase in that case?? check_iter is not touched anywhere inside the cases0000171d timeStamp = ((timeStamp * 0x41c64e6d) + 0x3039);
00001729 uint32_t rax_40 = (timeStamp >> 0x10);
00001743 check_itr = (rax_40 - (((int32_t)((((uint64_t)(rax_40 >> 2)) * 0x24924925) >> 0x20)) * 0x1c));check_itr is REinitialized by the timestamp for each instructioncheck_itr changes, so the instructions progressvalue_list IS modified in the block of code at the endinstructions are also modified during runtime value_list for check_valuecheck_itr will be initialized by the timestamp at the beginning block, it'll go through all the cases which will modify the other globals, then at the very end, it will modify only the instruction it just rancheck_itr progresses linearly, it should be fine0x5, because then the value associated with it is added to check_value at the endsub_opcode). This is a single integer, and changes between every instructionvalue_list is never accessed inside the casesinstruction/opcode == 1), it may set the instruction after executing to another value (edited) data_76f8 = ((int16_t)*(int32_t*)((((rdx_28 << 3) - rdx_28) << 2) + &data_7360));if statements at the end of case 1, the instruction will always be overwritten with the same thingsub_opcode is set to 0x7364 + check_itr at the beginning each instruction, and 0x7364 + check_itr is set to sub_opcode at the end of each instructionvalue_list is accessed during the casescheck_value in my decompilercheck_itr to itr and check_value to value since they're independent of the final check and the name is confusingsub_opcode). This is a single integer, and changes between every instruction case and not an if statement
case statements with a goto. The gotos are what I call "segments", and the sub_opcode is set to a static number lolcase statements with a bunch of gotoscase statements with a bunch of gotos